﻿namespace PerpetuumSoft.InstrumentationPDA
{
    using System;
    using System.Drawing;

    public class DigitalLED : Widget
    {
        private DigitsDisplay digits = new DigitsDisplay();

        public DigitalLED()
        {
            this.BackColor = Color.Black;
            this.Text = "0123456789";
        }

        protected override void DrawDynamic(Graphics g)
        {
            Rectangle workRectangle = this.WorkRectangle;
            base.DrawDynamic(g);
            Point pos = new Point(workRectangle.Left + 5, (workRectangle.Top + (workRectangle.Height / 2)) - (this.digits.DigitHeight / 2));
            this.digits.PaintString(g, pos, this.Text);
        }

        protected override void OnTextChanged(EventArgs e)
        {
            base.Invalidate();
            base.OnTextChanged(e);
        }

        protected override Size DefaultControlSize
        {
            get
            {
                return new Size(200, 40);
            }
        }

        public DigitsDisplay Digits
        {
            get
            {
                return this.digits;
            }
            set
            {
                this.digits = value;
                base.InvalidateStatic();
            }
        }
    }
}

